import Vue from 'vue'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import App from './App.vue'
import router from './router/index'
import Vuex from 'vuex'
import store from './store/index'
Vue.use(ElementUI)
Vue.use(Vuex)
router.beforeEach((to,from,next)=>{
  //获取状态
  let isLogin = sessionStorage.getItem('isLogin');
  //注销
  if (to.path=='/logout'){
    sessionStorage.clear();
    next({path:'/login'});
  }
  else if(to.path=='/login'){
    if (isLogin=='true'){
      //跳转首页
      next({path:'/main'})
    }
  }
  else if(isLogin==null){
    //跳转登录
    next({path:'/login'})
  }
  next();
})



new Vue({
  el: '#app',
  store,
  router,
  render: h => h(App),

});
